import {
  AddressDetail,
  BaseCmd,
  BaseQry,
  BaseView,
  CommonEnum,
  MediaFile,
} from '@/types/global-business';
import {
  TableColumnData,
  TableData,
} from '@arco-design/web-vue/es/table/interface';

export interface SubjectView extends BaseView {
  type?: CommonEnum;
  fullname?: string;
  code?: string;
  legalName?: string;
  legalPhone?: string;
  file?: MediaFile;
}

export interface CompanyView extends BaseView {
  bizScope?: CommonEnum;
  name?: string;
  fullname?: string;
  code?: string;
  chiefId?: number;
  contactName?: string;
  contactPhone?: string;
  subjectId?: number;
  area?: number;
  logo?: MediaFile;
  address?: AddressDetail;
  subject?: SubjectView;
}
export interface StoreView extends BaseView {
  companyId?: number;
  departmentId?: number;
  chiefId?: number;
  subjectId?: number;
  code?: string;
  name?: string;
  fullname?: string;
  area?: number;
  logo?: MediaFile;
  address?: AddressDetail;
  contactName?: string;
  contactPhone?: string;
  subject?: SubjectView;
}

// @ts-ignore
export interface DepartmentView extends TableData {
  id?: number; // ID
  parentId?: number; // 父ID
  parent?: DepartmentView; // 父组织
  children?: DepartmentView[]; // 儿子组织
  companyId?: number; // 公司ID
  type?: CommonEnum; // 类型
  name?: string; // 部门名称
  code?: string; // 部门编码，取名称首字母且大写
  status?: CommonEnum; // 状态：已启用｜已停用
  leaf?: boolean; // 是否叶子
  sort?: number; // 排序，值愈小优先级愈高
  storeId?: number; // 门店ID
  company?: CompanyView; // 公司信息
  store?: StoreView; // 门店信息
}

export interface DepartmentAddCmd extends BaseCmd {
  scene?: any;
  companyId?: number;
  type?: any;
  name?: string;
  parentId?: number;
  storeId?: number;
}

export interface DepartmentUptCmd extends BaseCmd {
  scene?: any;
  companyId?: number;
  id?: number;
  name?: string;
}

export interface DepartmentQry extends BaseQry {
  companyId?: number;
  id?: number;
  type?: any;
  status?: any;
  checkValid?: boolean;
  fetchCompany?: boolean;
  fetchStore?: boolean;
  fetchParent?: boolean;
  fetchChildren?: boolean;
}

export interface DepartmentListQry extends BaseQry {
  companyId?: number;
  parentId?: number;
  typeList?: any[];
  status?: any;
  idList?: number[];
  fetchRoot?: boolean;
  fetchAllChildren?: boolean;
  includeParent?: boolean;
}

export interface DepartmentTreeQry extends BaseQry {
  companyId?: number;
}

export const DEPARTMENT_COLUMNS: TableColumnData[] = [
  {
    title: '序号',
    dataIndex: 'idx',
    width: 60,
    fixed: 'left',
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 120,
  },
  {
    title: '工号',
    dataIndex: 'code',
    width: 120,
  },
  {
    title: '姓名',
    dataIndex: 'name',
    width: 120,
  },
  {
    title: '手机号',
    dataIndex: 'phone',
    width: 200,
  },
  {
    title: '部门',
    dataIndex: 'departmentId',
    width: 200,
  },
  {
    title: '性别',
    dataIndex: 'gender',
    width: 60,
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 200,
    fixed: 'right',
  },
];
